<template>
    <h2>登录</h2>
<table class="table table-bordered">
    <tr>
        <td>用户名</td>
        <td>
            <input type="text" v-model="info.name"/> 
        </td>
    </tr>
    <tr>
        <td>密码</td>
        <td>
            <input type="password" v-model="info.pwd"/> 
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <button clsss="btn btn-info" @click="login">登录</button>
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';
const router=useRouter()

const info=ref({
    name:'',
    pwd:''
})

const login=()=>{
    axios.get('https://localhost:7137/api/Work/UserLogin',{
        params:{
            name:info.value.name,
            pwd:info.value.pwd
        }
    })
    .then(res=>{
        if(res.data>0){
            alert('登录成功')
            router.push('/RoomShow')
        }
        else{
            alert('登录失败')
        }
    })
}

</script>